<?php
class video_language extends Model{
	public static function getTableName(){
		return 'video-language';
	}

	/*
	 * by donald
	 * at 2011-10-27
	 */
	public function set($object)
	{
		$this->video_id = $object->video_id;
		$this->language_id = $object->language_id;
		$this->title = $object->title;
		$this->description = $object->description;
		$this->subtitle = $object->subtitle;
	}

	/*
	 * by donald
	 */
	public function getAll($video_id)
	{
		return self::$dbo['w']->find(__CLASS__, 'video_id = ?', array('video_id' => $video_id));
	}

	/*
	 * by donald
	 */
	public function add_change_log($programme_id)
	{
		$field['type'] = $this->getTableName();
		$field['keys'] = array(
			'video_id' => $this->video_id,
			'language_id' => $this->language_id
		);
		$field['is_active'] = 1;
		$field['programme_id'] = $programme_id;
		$field['episode_id'] = 0;
		$field['is_publish'] = 0;

		change_log::updateOne($field);
	}

	/*
	 * by donald
	 */
	public function delete_change_log()
	{
		$type = $this->getTableName();
		$keys = array(
			'video_id' => $this->video_id,
			'language_id' => $this->language_id
		);
		$is_publish = 0;

		change_log::delTypeAndKeysLog($type, $keys, $is_publish);
	}

}
